﻿@{
    ViewBag.Title = "产品列表";
    Layout = "~/Areas/Shared/_spList.cshtml";
    ViewBag.ListActionURL = Url.Action("ProductList", "ProductManage", new { area = "Hiner" });
    ViewBag.AddActionURL = Url.Action("AddProduct", "ProductManage", new { area = "Hiner" });
    ViewBag.DelActionURL = Url.Action("DelProduct", "ProductManage", new { area = "Hiner" });
    ViewBag.EditActionURL = Url.Action("EditProduct", "ProductManage", new { area = "Hiner" });
    ViewBag.IdColumn = "ProductId";
    ViewBag.NameColumn = "ProductName";
    ViewBag.ListSortName = "";
    ViewBag.ListSortOrder = "";
    ViewBag.AddWindowTitle = "添加产品";
    ViewBag.EditWindowTitle = "编辑产品";   
}
@model Kaiser.Modules.Hiner.Models.Product.ProductBase
@section Script
{
    <script src="@Url.Content("~/Scripts/upload/ajaxfileupload.js")" type="text/javascript"></script>
    <script type="text/javascript">

        //    function SearchOK() {
        //        var BookName = $("#S_BookName").val();
        //        var BookCategoryName = $("#S_BookCategoryName").val();
        //        searchWin.window('close');
        //        grid.datagrid({ url: virpath + config.ListActionURL, queryParams: { BookName: BookName, BookCategoryName: BookCategoryName} });
        //    }

        config.GridOption.columns = [[
            { field: 'ProductHDECode', title: 'HDE Code', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductHinerCode', title: 'HINER Code', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductOERef', title: 'OE Ref.', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductImgUrl', title: 'Image', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductCarModel', title: 'Car Model', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductDesc', title: '备注', width: 60, sortable: true, rowspan: 2 },
            { field: '', title: 'Packing', width: 60, sortable: true, colspan: 4 },

            { field: 'ProductName', title: '产品名称', width: 60, sortable: true, rowspan: 2 },
            { field: 'ProductSPEC', title: '规格', width: 60, sortable: true, rowspan: 2 },
            { field: 'SupplierName', title: '供应商', width: 60, sortable: true, rowspan: 2 }
        ], [
             { field: 'InnerPackageImgUrl', title: 'Inner Package Img', width: 90, sortable: true },
              { field: 'InnerPackageSize', title: 'Inner Package Size', width: 90, sortable: true },
              { field: 'OuterPackageImgUrl', title: 'Outer Package Img', width: 90, sortable: true },
              { field: 'OuterPackageSize', title: 'Outer Package Size', width: 90, sortable: true }
        ]];




        var g = $('#SupplierCode').combogrid({
            panelWidth: 500,
            url: '@Url.Action("GetSupplierList", "SupplierManage", new { area = "Hiner" })',
            idField: 'SupplierCode',
            textField: 'SupplierName',
            mode: 'remote',
            fitColumns: true,
            columns: [[
                { field: 'SupplierCode', title: '供应商编码', width: 60 },
                { field: 'SupplierName', title: '供应商名称', width: 80 }
            ]]
        });

       
      

        


        function showImage() {
            var o = $("#fileToUpload").get(0);
            if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value)) {
                alert('只能上传jpg,bmp,gif,png格式图片!');
                o.outerHTML = o.outerHTML;
                return false;
            } else {
                $("#buttonUpload").click();
            }

        }

        //获取file完整路径

        function getFullPath() {
            var obj = document.getElementById("fileToUpload");
            if (obj) {
                if (window.navigator.userAgent.indexOf("MSIE") >= 1)    //ie  
                {
                    obj.select();
                    obj.blur();
                    return document.selection.createRange().text;
                } else if (window.navigator.userAgent.indexOf("Firefox") >= 1)             //firefox  
                {
                    if (obj.files) {
                        return obj.files.item(0).getAsDataURL();
                    }
                    return obj.value;
                }
                return obj.value;
            }
        }

        $("#ImageTd").hide();
        //上传

        function ajaxFileUpload() {
            $("#loading")
                .ajaxStart(function () {
                    $(this).show();
                })
                .ajaxComplete(function () {
                    $(this).hide();
                });

            $.ajaxFileUpload(
                {
                    url: '@Url.Action("UploadFiles", "ProductManage", new { area = "Hiner" })?Code=' + $("#ProductId").val(),
                    secureuri: false,
                    fileElementId: 'fileToUpload',
                    dataType: 'json',
                    success: function (data, status) {
                        if (typeof (data.error) != 'undefined') {
                            if (data.error != '') {
                                alert(data.error);
                            } else {
                                alert(data.msg);
                            }
                        } else {
                            $("#ImageTd").show();
                            // $("#ImageTd").append("<img style='width:50px;height:50px;' src='" + data.msg + "'  /> ");
                            $("#ProductImgUrl").val(data.msg);
                            $("#ImageTd").attr("src", data.msg);

                        }
                    },
                    error: function (data, status, e) {
                        alert(e);
                    }
                }
            )

            return false;
        }

        $(function () {

            function edit() {
                alert("1");

            }

            if ($("#ProductImgUrl").val() != undefined && $("#ProductImgUrl").val() != null && $("#ProductImgUrl").val() != "") {
                $("#ImageTd3").show();
                $("#ImageTd3").attr("src", $("#ProductImgUrl").val());
            }


            dlg_Edit.SubmitBeforeLoad = function (parameters) {
                var text = $('#SupplierCode').combogrid('getText');
                $("#SupplierName").val(text);


            };


        });


    </script>
}
<div style="display: none">
    <div id="Dlg-CategoryTree" style="width: 350px; height: 220px;">
        <ul class="easyui-tree" id="SelectCategoryTree">
        </ul>
    </div>
    <div id="Dlg-Edit" title="编辑" style="width: 700px; height: 560px;" buttons="#buttons">
        <div style="padding: 10px">
            <form method="post">
            <table>
                <tr>
                    <td class="itemtxt" style="text-align: right">
                        名称：
                    </td>
                    <td>
                        @Html.HiddenFor(m => Model.ProductId)
                        @Html.TextBoxFor(m => Model.ProductName, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td class="itemtxt" style="text-align: right">
                        HDE Code：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductHDECode, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Hiner Code：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductHinerCode, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        OE Ref：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductOERef, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Car Model：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductCarModel, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        供应商：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.SupplierCode, new { @Class = "easyui-validatebox", @style = "width: 200px;", @maxlength = "10" })
                          @Html.HiddenFor(m => Model.SupplierName)
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Inner Package Img：
                    </td>
                    <td>
                        <!--id="ImageTd"-->
                        <input id="fileToUpload1" type="file" size="45" name="fileToUpload" onchange="showImage(this)">
                        <input type="button" id="buttonUpload1" value="上传" style="display: none;" onclick="return ajaxFileUpload();">
                        <br/>
                        @Html.HiddenFor(m => Model.InnerPackageImgUrl)
                        <img id="ImageTd1" width="120px" height="120px" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Inner Package Size：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.InnerPackageSize, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Outer Package Img：
                    </td>
                    <td>
                        <input id="fileToUpload2" type="file" size="45" name="fileToUpload" onchange="showImage(this)"/>
                        <input type="button" id="buttonUpload2" value="上传" style="display: none;" onclick="return ajaxFileUpload();"/>
                        <br/>
                        @Html.HiddenFor(m => Model.OuterPackageImgUrl)
                        <img id="ImageTd2" width="120px" height="120px" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Outer Package Size：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.OuterPackageSize, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        备注：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductDesc, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        产品描述：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductDepict, new { @Class = "easyui-validatebox", @required = "true", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        图片：
                    </td>
                    <td>
                        <!--id="ImageTd"-->
                        <input id="fileToUpload" type="file" size="45" name="fileToUpload" onchange="showImage(this)">
                        <input type="button" id="buttonUpload" value="上传" style="display: none;" onclick="return ajaxFileUpload();">
                        <br/>
                        @Html.HiddenFor(m => Model.ProductImgUrl)
                        <img id="ImageTd3" width="120px" height="120px" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        价格：
                    </td>
                    <td>
                        @Html.TextBoxFor(m => Model.ProductPrice, new { @Class = "easyui-numberbox", @style = "width: 200px;", @maxlength = "10" })
                    </td>
                </tr>
            </table>
            </form>
        </div>
    </div>
    <div id="search-window" title="搜索" style="width: 550px; height: 300px; padding: 10px 20px">
        <div style="padding: 20px 20px 40px 40px;">
            <form method="post" id="Form2">
            <table>
                <tr>
                    <td class="itemtxt" style="text-align: right">
                        HDE Code：
                    </td>
                    <td>
                        @Html.TextBox("HDECode", "")
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        Hiner Code：
                    </td>
                    <td>
                        @Html.TextBox("HinerCode", "")
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        OE Ref：
                    </td>
                    <td>
                        @Html.TextBox("OERef.", "")
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        请选择供应商：
                    </td>
                    <td>
                        @Html.DropDownList("OERef.", new List<SelectListItem>(), new { style = "width:100px" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        价格范围：
                    </td>
                    <td>
                        @Html.TextBox("MinPrice.", "", new { style = "width:30px" })到 @Html.TextBox("MaxPrice.", "", new { style = "width:30px" })
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <div style="text-align: center; padding: 5px;">
            <a href="javascript:void(0)" onclick="SearchOK()" id="btn-search" icon="icon-ok">确定</a>
            <a href="javascript:void(0)" onclick="closeSearchWindow()" id="btn-search-cancel"
                icon="icon-cancel">取消</a>
        </div>
    </div>
</div>
